package com.tudouji.project.quality.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.quality.domain.Qamain;
import com.tudouji.project.quality.service.IQamainService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 质检标准Controller
 *
 * @author wf
 * @date 2021-03-09
 */
@RestController
@RequestMapping("/quality/qamain")
public class QamainController extends BaseController
{
    @Autowired
    private IQamainService qamainService;

    /**
     * 查询质检标准列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qamain qamain)
    {
        startPage();
        List<Qamain> list = qamainService.selectQamainList(qamain);
        return getDataTable(list);
    }

    /**
     * 导出质检标准列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:export')")
    @Log(title = "质检标准", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Qamain qamain)
    {
        List<Qamain> list = qamainService.selectQamainList(qamain);
        ExcelUtil<Qamain> util = new ExcelUtil<Qamain>(Qamain.class);
        return util.exportExcel(list, "qamain");
    }

    /**
     * 获取质检标准详细信息
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(qamainService.selectQamainById(guid));
    }

    /**
     * 新增质检标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:add')")
    @Log(title = "质检标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qamain qamain)
    {
        return toAjax(qamainService.insertQamain(qamain));
    }

    /**
     * 修改质检标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:edit')")
    @Log(title = "质检标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qamain qamain)
    {
        return toAjax(qamainService.updateQamain(qamain));
    }

    /**
     * 删除质检标准
     */
    @PreAuthorize("@ss.hasPermi('quality:qamain:remove')")
    @Log(title = "质检标准", businessType = BusinessType.DELETE)
    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(qamainService.deleteQamainByIds(guids));
    }

    @GetMapping("/findQamainList")
    public AjaxResult findQamainList(Qamain qamain)
    {
        List<Qamain> list = qamainService.selectQamainList(qamain);
        return AjaxResult.success(list);
    }
}
